import java.util.Stack;
//两个栈实现队列
public class MyQueue {
    private Stack<Integer> stack1 ;
    private Stack<Integer> stack2 ;

    public MyQueue() {
       stack1 = new Stack<>();
         stack2 = new Stack<>();
    }

    //选择 stack1 存放入队列时的数据
    public void push(int x) {
        stack1.push(x);
    }

    //选择 stack2 存放出队列时的数据
    public int pop() {
        if(empty()){
            return -1;
        }
        if(stack2.empty()){
            while(!stack1.empty()){
                stack2.push(stack1.pop());
            }
        }
            return stack2.pop();

    }

    public int peek() {
        if(empty()){
            return -1;
        }
        if(stack2.empty()){
            while(!stack1.empty()){
                stack2.push(stack1.pop());
            }
        }
            return stack2.peek();
    }

    public boolean empty() {
        return stack1.empty() && stack2.empty();
    }
}
